package com.xxxx.controller;


import com.xxxx.pojo.Department;
import com.xxxx.pojo.R;
import com.xxxx.service.DepartmentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author chao
 * @since 2022-09-26
 */
@RestController
@RequestMapping("/system/basic/department")
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;


    @ApiOperation(value = "获取所有部门列表")
    @GetMapping("/")
    public R getDepartments() {
        List<Department> departmentList = departmentService.getAllDepartmentList();
        return R.success(departmentList);
    }

    @ApiOperation(value = "添加部门")
    @PostMapping("/")
    public R saveDepartment(@RequestBody Department department) {

        return departmentService.saveDepartment(department);
    }

    @ApiOperation(value = "删除部门")
    @DeleteMapping("/{id}")
    public R deleteDepartment(@PathVariable("id") Integer id) {
        return departmentService.deleteDepartment(id);
    }
}
